﻿@{
    Layout = null;
}
@model RiderShop.Mobile.Modle.MyAccount.MyPromotionCodeModel

@{
    string shareTitle = "蓉记红包抢先拿！";
    if (Request.QueryString["pc"].ToUpper() == "YOUCHA9")
    {
        shareTitle = "回坊味道，蓉记红包限量换领孙庆海五仁油茶，鲜到先得！";
    }
}
<!doctype html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>小伙伴们，快来领蓉记鲜鲜鲜红包吧</title>
    <!-- Bellows Styles -->
    <link href="~/Themes/RongJi/Style/luckybag/css/style.css" rel="stylesheet" />
</head>
<body>
    <div class="tops">
        <img src="~/Themes/RongJi/Style/luckybag/imgs/top.jpg" class="top_bg" />
        <div class="card_wrapper">
            <img src="~/Themes/RongJi/Style/luckybag/imgs/card.png" class="card" />
        </div>
        @{
            string discount = "";
            if (Model.PromotionCodeList != null)
            {
                var thridUserId = Kevin.Shop.Business.Core.Components.Cookie.KevinCookieManager.Get("openid");
                var pcode = Model.PromotionCodeList.FirstOrDefault(p => p.ThirdUserId == "weixing_" + thridUserId);
                discount = pcode == null ? "" : pcode.CodeDiscount.ToString("N0");
            }
        }
        <span class="mymoney">@discount 元</span>
        <div class="use">
            @if (Request.QueryString["pc"].Trim().ToUpper() == "YOUCHA9")
            {
                <a href="/Product/ProductDetail?prd=10410002013">立即兑换</a>
            }
            else
            {
                <a href="/">立即使用</a>
            }
        </div>
    </div>

    <div class="fellows">
        <span class="title-wrapper">
            <span class="title">看看小伙伴们手气如何</span>
        </span>

        @if (Model.PromotionCodeList != null)
        {
            foreach (var code in Model.PromotionCodeList)
            {
                <dl>
                    <dt>
                        <img src="@(string.IsNullOrEmpty(code.ThirdUserHeader) ? "/Themes/RongJi/Style/luckybag/imgs/1.jpg" : code.ThirdUserHeader)" alt="@code.ThirdUserName" />
                    </dt>
                    <dd>
                        <h5>@code.ThirdUserName  <time>@code.ReceiveDate.ToString("yyyy-MM-dd")</time></h5>
                        <p>哈哈，小手一抖红包到手</p>
                        <span>@code.CodeDiscount.ToString("N0") 元</span>
                    </dd>
                </dl>
            }
        }

    </div>

    <div class="fellows">
        <span class="sharetitle">
            @if (Request.QueryString["pc"].Trim().ToUpper() == "YOUCHA9")
            {
                <p>分享好友即可领取“蓉记鲜红包”（该红包可用于兑换孙庆海五仁油茶），触即可及！</p>
            }
            else if (Request.QueryString["pc"].Trim().ToUpper() == "XINCHUN69")
            {
                <p>订单满69元可以使用</p>
            }

        </span>
    </div>

    <div class="footer">
        <div class="shareLucky">
            <a class="fl" href="/Promotion/ShareLuckyBag?s=1&pc=@Request.QueryString["pc"]">我也要发红包</a>
            <a class="fr" href="/myaccount/mypromotioncode?promotionType=1">我的红包</a>
        </div>

    </div>
    @if (!string.IsNullOrEmpty(Model.Message) && Model.Message != "已领取该用户分享的红包")
    {
        <div class="shareMessage" onclick="hideShare()">
            <p>@Model.Message</p>
        </div>
    }
    <script type="text/javascript">

        function hideShare() {
            document.getElementsByClassName('shareMessage')[0].style.display = 'none';
        }

    </script>

    <script src="~/Themes/RongJi/Style/base/js/weixinshare.js"></script>

    <script type="text/javascript">
        window.config = {
            link: '@Html.Raw("http://m.rongji365.com/promotion/MyLuckyBag?pc=" + @Request.QueryString["pc"] + "&fid=" + @Kevin.Shop.Business.Core.Components.Cookie.KevinCookieManager.Get("openid"))',
            imgUrl: 'http://m.rongji365.com/staticResource/imgs/hongbao_icon.jpg',
            img_url: 'http://m.rongji365.com/staticResource/imgs/hongbao_icon.jpg',
            title: '@shareTitle',
            desc: '@Kevin.Shop.Business.Core.Components.Cookie.KevinCookieManager.Get("nickname") 送你蓉记鲜鲜鲜红包，还不快来领！'
        };
        //function onBridgeReady() {
        //    WeixinJSBridge.call('hideOptionMenu');
        //}

        //if (typeof WeixinJSBridge == "undefined") {
        //    if (document.addEventListener) {
        //        document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        //    } else if (document.attachEvent) {
        //        document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
        //        document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        //    }
        //} else {
        //    onBridgeReady();
        //}
    </script>

    <script src="~/Themes/RongJi/Style/base/js/jquery-1.10.1.min.js"></script>
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
        $(function () {
            var postData = {
                "currentUrl": window.location.href.replace(window.location.hash, '')
            }
            $.post("http://m.rongji365.com/WeixinJsSdk/ConfigScriptJson", postData, function (wxConfig) {

                wx.config(wxConfig);

                wx.ready(function () {
                    // config信息验证后会执行ready方法，所有接口调用都必须在config接口获得结果之后，config是一个客户端的异步操作，所以如果需要在页面加载时就调用相关接口，则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口，则可以直接调用，不需要放在ready函数中。
                    var config = window.config;
                    wx.onMenuShareAppMessage(config);
                    wx.onMenuShareTimeline(config);
                    wx.onMenuShareQQ(config);
                    wx.onMenuShareWeibo(config);

                    //wx.hideOptionMenu();
                });

                wx.error(function (res) {

                    // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。

                });
            });
        });
    </script>
    <script type="text/javascript" src="http://js.tongji.linezing.com/3547905/tongji.js"></script>

</body>
</html>
